import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

let routes = [
  {
    path: '/',
    component: () => import("@/layout/DefaultLayout"),
    name: 'ToolsHome',
    redirect: '/ToolsHome',
    children:[
      {
        path: '/',
        component: () => import("@/page/ToolsHome"),
        name: 'ToolsHome',
      },

      {
        path: '/cssTools',
        component: () => import("@/page/CssTools"),
        name: 'CssTools',
      },

      {
        path: '/jsonTools',
        component: () => import("@/page/JsonTools"),
        name: 'JsonTools',
      },

      {

        path: '/xmlTools',
        component: () => import("@/page/XmlTools"),
        name: 'XmlTools',
      },


      {
        path: '/htmlTransfer',
        component: () => import("@/page/HtmlTransfer"),
        name: 'HtmlTransfer',
      },

      {
        path: '/uuidTools',
        component: () => import("@/page/UUIDTools"),
        name: 'UUIDTools',
      },
      {
        path: '/encryptionTool',
        component: () => import("@/page/EncryptionTool"),
        name: 'encryptionTool',
      },
      //   工具详情页
      {
        path: '/ToolsDetails/:toolName',
        component: () => import("@/page/ToolsDetails.vue"),
        name: 'toolDetails',
      },
      {
        path: '/Activity',
        component: () => import("@/page/Activity.vue"),
        name: 'Activity',
      },
      {
        path: '/ActivityQuery',
        component: () => import("@/page/ActivityQuery.vue"),
        name: 'ActivityQuery',
      },

    ]
  },


  {
    path: '/certificateQuery/:certificateUuid',
    component: () => import("@/layout/PhoneLayout"),
    name: 'certificateQuery',
    children: [
      {
        path: '/certificateQuery/:certificateUuid',
        component: () => import("@/page/CertificateQuery"),
        name: 'certificateQuery',
      },
      {
        path: '/CertificateQueryNotFound',
        component: () => import("@/page/CertificateQueryNotFound"),
        name: 'CertificateQueryNotFound',
      },
    ]
  },

  //   path: '/404',
  //   component:() => import("@/components/404"),
  //   name: '404'
  // },

]



// 解决相同路由下报错问题
//push
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

//replace
const VueRouterReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace (to) {
  return VueRouterReplace.call(this, to).catch(err => err)
}


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

export default router
